package com.mz.ozy.activity.c2c;

import android.app.Activity;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.mz.ozy.R;
import com.previewlibrary.GPreviewActivity;
import com.previewlibrary.GPreviewBuilder;
import com.previewlibrary.enitity.ThumbViewInfo;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;

public class PhotoScanNohitActivity extends GPreviewActivity {

    public static void startPhotoScan(Activity context, List<String> mImages, int pos) {
        //组织数据
        ArrayList<ThumbViewInfo> mThumbViewInfoList = new ArrayList<>(); // 这个最好定义成成员变量
        ThumbViewInfo item;
        mThumbViewInfoList.clear();
        for (int i = 0; i < mImages.size(); i++) {
            Rect bounds = new Rect();
            //new ThumbViewInfo(图片地址);
            item = new ThumbViewInfo(mImages.get(i));
            item.setBounds(bounds);
            mThumbViewInfoList.add(item);
        }

        //打开预览界面
        GPreviewBuilder.from(context)
                //是否使用自定义预览界面，当然8.0之后因为配置问题，必须要使用
                .to(PhotoScanNohitActivity.class)
                .setData(mThumbViewInfoList)
                .setCurrentIndex(pos)
                .setSingleFling(true)
                .setType(GPreviewBuilder.IndicatorType.Number)
                // 小圆点
                //  .setType(GPreviewBuilder.IndicatorType.Dot)
                .start();//启动
    }

    ImageView ivBack;
    TextView tvCenterTitle;
    TextView mLtAddDot;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
        ivBack = findViewById(R.id.back);
        tvCenterTitle = findViewById(R.id.tv_center_title);
        tvCenterTitle.setText("预览");
        mLtAddDot = findViewById(R.id.ltAddDot);
        mLtAddDot.setVisibility(View.GONE);
        ivBack.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    /***
     * 重写该方法
     * 使用你的自定义布局
     **/
    @Override
    public int setContentLayout() {
        return R.layout.activity_image_look;
    }
}
